#include "helper/transaction/Transaction.h"

namespace helper {
namespace transaction {

Transaction::Transaction()
: _status(INITED)
{
}
Transaction::~Transaction()
{
}

std::error_code Transaction::begin() {
  if(isInited()){
    auto && ec = _begin();
    _status = STARTED;
    return ec;
  }
  return std::make_error_code(std::errc::operation_not_permitted);
}
std::error_code Transaction::commit() {
  if(isStarted()){
    auto && ec = _commit();
    _status = COMMITTED;
    return ec;
  }
  return std::make_error_code(std::errc::operation_not_permitted);
}
std::error_code Transaction::rollback() {
  if(isStarted()){
    auto && ec = _rollback();
    _status = ROLLBACKED;
    return ec;
  }
  return std::make_error_code(std::errc::operation_not_permitted);
}

std::error_code Transaction::_begin() {
  return std::error_code();
}
std::error_code Transaction::_commit()  {
  return std::error_code();
}
std::error_code Transaction::_rollback() {
  return std::error_code();
}

}//namespace transaction
}//namespace helper
